package com.pangda.pojo.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Accessors(chain = true)
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "层级树返回对象")
public class NodeVo implements Serializable {
    @ApiModelProperty(value = "节点id")
    private Integer id;

    @ApiModelProperty(value = "父节点id")
    private Integer parentId;

    @ApiModelProperty(value = "节点名称")
    private String label;
    @ApiModelProperty(value = "子节点列表")
    private List<NodeVo> children = new ArrayList<>();

    // 添加子节点
    public void addChild(NodeVo nodeVo) {
        children.add(nodeVo);
    }

}
